package com.bicon.botu.finance.payment.weixin.utils;

import java.util.Random;


public class CodeUtil {
	private static final char[] src = "1234567890".toCharArray();
	private static final char[] srcAbc = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();

	public static String Code() {
		int len = 8;
		char[] buf = new char[len];
		for (int i = 0; i < buf.length; ++i) {
			buf[i] = src[Math.abs(new Random().nextInt(src.length))];
		}
		return new String(buf);
	}

	public static String Code(int len) {
		char[] buf = new char[len];
		for (int i = 0; i < buf.length; ++i) {
			buf[i] = srcAbc[Math.abs(new Random().nextInt(src.length))];
		}
		return new String(buf);
	}

	public static String StringFilter(String str) {
//		str = str.replaceAll("[\\pP|~|$|^|<|>|\\||\\+|=]*", "");
//		str = str.replaceAll("[\\pP|~|$|^|<|>|\\||\\+|=]*", "");
		str=str.replace("<", "");
		str=str.replace(">", "");
		str=str.replace("/", "");
		return str;
	}

}
